const Router = require('koa-router')
const user = require('./controller/user')
const article = require('./controller/article')

const router = new Router({
  prefix: '/api'
})

router
  // 用户登录
  .post('/user/login', user.login)
  // 用户注册
  .post('/user/register', user.register)
  // 用户资料修改
  .put('/user/profile', user.modify)
  // 重置用户密码
  .put('/user/password-reset', user.passwordReset)
  // 删除用户
  .delete('/user/delete', user.remove)
  // // 发布文章
  .post('/articles', article.create)
  // 获取文章详情
  .get('/articles/:id', article.detail)
  // 编辑文章
  .put('/articles/:id', article.modify)
  // 删除文章
  .delete('/articles/:id', article.remove)
  // 点赞文章
  .post('/articles/:id/stars', article.star)
  // 发布评论
  .post('/articles/:id/comments', article.comment)
  // 删除评论
  .delete('/articles/:id/comments/delete', article.removeComment)

module.exports = router
